package com.sentrix.auto.printercenter.infrastructure.scheduler;

import com.sentrix.auto.printercenter.application.PrinterAgentDetectionService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class PrinterDetectionScheduler {

    @Resource
    private PrinterAgentDetectionService detectionService;


    @Scheduled(fixedRate = 1000 * 30, initialDelay = 1000 * 30)
    public void detectPrinterStatus() {
        log.info("开始检测打印机及打印机状态");
        try {
            // 调用应用层服务执行检测逻辑
            detectionService.detectOfflineAndNewPrinters();
            log.info("打印机状态检测完成");
        } catch (Exception e) {
            log.error("检测打印机及打印机状态异常:{}", e.getMessage());
        }

    }
}
